function [first,last] = getIndexBounds(numberOfPoints, numberOfWorkers, worker)

if(worker > numberOfWorkers)
    error('The worker index should be less than the total number of workers');
end;

if(numberOfWorkers > numberOfPoints)
    if(numberOfPoints >= worker)
        first = worker;
        last = worker;
    else
        % this worker does not get anything...
        first = NaN;
        last = NaN;
    end

else
    perWorker = floor(numberOfPoints/numberOfWorkers);
    rest = rem(numberOfPoints,numberOfWorkers);
    first = (worker-1)*perWorker +1 + min(worker-1, rest);
    last = worker*perWorker + min(worker,rest);   
end;